import request from './request'

// 封装GET请求
export function get<T>(url : string, params ?: any) : Promise<T> {
	return request.get<T>(url, { params })
		.then(response => response.data)
		.catch(error => {
			throw error;
		});
}
// 封装POST请求
export function post<T>(url: string, data?: any): Promise<T> {
   return request.post<T>(url, data)
      .then(response => response.data)
      .catch(error => {
         throw error;
      });
}

// put封装修改请求
export function put<T>(url: string, data?: any): Promise<T> {
   return request.put<T>(url, data)
      .then(response => response.data)
      .catch(error => {
         throw error;
      });
}
//delete 封装删除请求
export function del<T>(url: string,data: any): Promise<T> {
   return request.delete<T>(url)
      .then(response => response.data)
      .catch(error => {
         throw error;
      });
}


